import allure
from selenium.webdriver.common.by import By

from src.PO.base import Base
from src.PO.product_edit_page import ProductEidtPage


@allure.feature("商品搜索界面")
class ProductSearchPage(Base):
    __ID=(By.CSS_SELECTOR,"tbody>tr>td:nth-child(2)")
    __SCALE=(By.CSS_SELECTOR,"tbody>tr>td:nth-child(1)")
    __NUMBER=(By.CSS_SELECTOR,".el-form.table-expand.el-form--label-left>div:nth-child(1)>div")
    __NAME=(By.CSS_SELECTOR,"tbody>tr>td:nth-child(3)")
    __EDIT=(By.CSS_SELECTOR,"tbody>tr>td:nth-child(12)>div>button:nth-child(1)")
    def get_id(self):
        with allure.step("获取商品ID"):
            self.find_and_click(*self.__SCALE)
            pr_id=self.find(*self.__ID)
            id=pr_id.text
        return id
    def get_number(self):
        with allure.step("获取商品编号"):
            self.find_and_click(*self.__SCALE)
            pr_nu=self.find(*self.__NUMBER)
            number=pr_nu.text
        return number
    def get_name(self):
        with allure.step("获取商品名称"):
            self.find_and_click(*self.__SCALE)
            pr_na=self.find(*self.__NAME)
            name=pr_na.text
        return name

    def click_to_edit(self):
        with allure.step("点击编辑"):
            self.find_and_click(*self.__EDIT)
        return ProductEidtPage(self.driver)

